import { PRODUCT_TYPES } from '../index';
const formItemList = [
  {
    prop: 'categoryPath',
    label: '分类',
    type: 'input'
  },
  {
    prop: 'spuNo',
    label: 'SPU编码',
    type: 'input'
  },
  {
    prop: 'productName',
    label: '商品名称',
    type: 'input'
  },
  {
    prop: 'brandName',
    label: '商品品牌',
    type: 'input'
  },
  {
    prop: 'productType',
    label: '商品类型',
    type: 'select',
    clearable: true,
    options: PRODUCT_TYPES
  },
  {
    prop: 'operName',
    label: '提交人',
    type: 'input'
  },
]
const renderSpecialColumn = (h, row, parent) => {
  return function (formatKey, jumpKey) {
    if (row[formatKey]) {
      return (
        <el-link
          type = { parent.formatLinkType(row[formatKey]) }
          onClick = {() => parent.handleLinkJump(row, jumpKey, row[formatKey])}
        >
          { row[`${formatKey}Str`] }
        </el-link>
      );
    }
    return '';
  }
}
const getTableColumns = (parent) => {
  return [
    {
      title: '单据编号',
      key: 'recordNo',
      width: 200,
      fixed: 'left'
    },
    {
      title: '分类',
      key: 'categoryPath'
    },
    {
      title: 'SPU编码',
      key: 'spuNo',
    },
    {
      title: '商品名称',
      key: 'productName',
    },
    {
      title: '品牌',
      key: 'brandName'
    },
    {
      title: '商品类型',
      key: 'productTypeStr'
    },
    {
      title: '管理区域',
      key: 'manageAreaName'
    },
    {
      title: '提交人',
      key: 'operName'
    },
    {
      title: '提交部门',
      key: 'operDeptName'
    },
    {
      title: '创建日期',
      key: 'createOpeTime',
      width: 150
    },
    {
      title: '商品SKU信息(包装)',
      key: 'packageAddState',
      width: 150,
      render: (h, { row }) => {
        return renderSpecialColumn(h, row, parent)('packageAddState', 'skuPackageInfo');
      }
    },
    {
      title: '供货信息',
      key: 'supplyPriceAddState',
      render: (h, { row }) => {
        return renderSpecialColumn(h, row, parent)('supplyPriceAddState', 'skuSupplyInfo');
      }
    },
    {
      title: '售价信息',
      key: 'salePriceAddState',
      render: (h, { row }) => {
        return renderSpecialColumn(h, row, parent)('salePriceAddState', 'skuPriceInfo');
      }
    },
    {
      title: '图文介绍',
      key: 'picAddState',
      render: (h, { row }) => {
        return renderSpecialColumn(h, row, parent)('picAddState', 'skuImgTextInfo');
      }
    },
    {
      title: '验收标准',
      key: 'acceptanceAddState',
      render: (h, { row }) => {
        return renderSpecialColumn(h, row, parent)('acceptanceAddState', 'skuCheckInfo');
      }
    },
    {
      title: '资质信息',
      key: 'qualificationAddState',
      render: (h, { row }) => {
        return renderSpecialColumn(h, row, parent)('qualificationAddState', 'skuQualificationInfo');
      }
    }
  ]
}
export {
  formItemList,
  getTableColumns
}
